class Solution:
    def cuttingRope(self, n: int) -> int:
        # 数学推导，n等于3最优
        if n < 4:
            return n-1
        res = 1
        while n > 4:
            res *= 3
            n -= 3
        return res * n